package com.wr.common.hystrix;

import com.alibaba.fastjson.JSON;
import com.google.common.collect.Lists;
import com.wr.common.constans.HttpStatusConstans;
import com.wr.common.utils.BaseResult;

/**
 * 通用的熔断方法
 */
public class Fallback {

    public static String badGateway(){
        /**
         * 502错误
         */
        BaseResult baseResult = BaseResult.notOk(Lists.newArrayList(
                new BaseResult.Error(
                        HttpStatusConstans.BAD_GATEWAY.getStatus(),
                        HttpStatusConstans.BAD_GATEWAY.getContent()
                )));
        try {
            return JSON.toJSONString(baseResult);
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }
}
